/*
 *
 *  * Copyright (c) 2016. For Intelligent Group.
 *
 */

package com.intelligent.ispc.client.event;

import com.google.common.eventbus.Subscribe;
import com.intelligent.ispc.client.utils.EventBusUtils;
import com.intelligent.ispc.event.TaskProcessChangeEvent;
import com.intelligent.ispc.event.TaskProcessUrlEvent;

/**
 * Created by Peter on 2016/9/6.
 */
public class TaskProcessChangeListener {

    /**
     * Subscribe event for finish process.
     *
     * @param event TaskProcessChangeEvent
     */
    @Subscribe
    public void done(TaskProcessChangeEvent event) {
        try {
            EventBusUtils.post(new StatusBarProcessChangeEvent(event.getKey(), event.getPresent(), event.getLog()));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * Subscribe event for creating url.
     *
     * @param event TaskProcessUrlEvent
     */
    @Subscribe
    public void addUrl(TaskProcessUrlEvent event) {
        try {
            EventBusUtils.post(new StatusBarProcessUrlEvent(event.getKey(), event.getUrl()));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
